package com.aike.controller;

import com.aike.service.TaskService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/Grade", produces={"text/html;charset=UTF-8;","application/json;"})
public class TaskController {

    @Autowired
    private TaskService taskService;

    @RequestMapping("/taskPage")
    public String taskPage(@RequestParam("userId") Integer userId)
    {
        return taskService.getTaskList(userId);
    }

    @RequestMapping("/taskShowPage")
    public String taskShowPage(@RequestParam("taskId") Integer taskId, @RequestParam("userId") Integer userId)
    {
        return taskService.getTaskShow(taskId, userId);
    }

    @RequestMapping("addNewTask")
    public String addNewTask(@RequestParam("userId") Integer userId, @RequestParam("taskTitle") String taskTitle, @RequestParam("taskMain") String taskMain)
    {
        return taskService.addNewTask(userId, taskTitle, taskMain);
    }

    @RequestMapping("deleteTaskById")
    public String deleteTaskById(@RequestParam("taskId") Integer taskId)
    {
        return taskService.deleteTaskById(taskId);
    }



    @RequestMapping("updateTaskById")
    public String udpateTaskById(@RequestParam("taskId") Integer taskId, @RequestParam("taskTitle") String taskTitle, @RequestParam("taskMain") String taskMain)
    {
        return taskService.updateTaskById(taskId, taskTitle, taskMain);
    }
}
